package model.algorithm;

import java.util.NoSuchElementException;

import model.datastructure.BlockSurface2D;
import model.datastructure.FieldSurface2D;
import model.datastructure.ISurface;

public class SteppingSurface2DIterator extends AbstractSurfaceIterator {

	private int mBlockWidth;

	public SteppingSurface2DIterator() {
		index = 0;
		name = "Stepping It";
	}

	public boolean hasNext() {
		/* can another blockSurface be next? */
		return index <= ( mFieldWidth - mBlockWidth );
	}

	public Integer next() {
		if( ! hasNext() ) {
			throw new NoSuchElementException( "Please use the hasNext() method, dimwit" );
		}
		return index ++;
	}

	@Override
	public void reset( FieldSurface2D fieldSurface, ISurface blockSurface , boolean lookahead) {
		mFieldWidth = fieldSurface.getWidth();
		mBlockWidth = ( ( BlockSurface2D ) blockSurface ).getWidth();
		index = 0;
	}

	/**
	 * Does nothing
	 */
	public void remove() {
		// does nothing
	}
	
	
}